package com.atguigu.gmall.task.controller;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/8/2 9:46
 * @Version 1.0
 */
@Component
public class TaskController {

    @Autowired
    private RabbitService rabbitService;

    //  定时任务.
    @XxlJob("demo")
    public void demo(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("hello");
        //  实际的秒杀业务要执行发送消息代码.
        //  rabbitService.sendMsg(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"啥都行...");
    }
}
